Fix TikTok link preview (use video thumbnail)#3451
Fix TikTok link preview (use video thumbnail)#3451bikalsiwakoti wants to merge 1 commit intodubinc:mainfrom
Conversation
|
@bikalsiwakoti is attempting to deploy a commit to the Dub Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughEnhanced the metatags API to handle TikTok links by detecting short links, following redirects to resolve final URLs, and prioritizing TikTok oEmbed thumbnails over favicons when extracting image metadata for link previews. Changes
Sequence DiagramsequenceDiagram
participant Client
participant getMetaTags as getMetaTags()
participant Fetch as Fetch & Redirect
participant TikTok as TikTok oEmbed
participant Meta as Metadata Return
Client->>getMetaTags: Request metadata for URL
alt TikTok Short Link Detected
getMetaTags->>Fetch: fetchWithTimeout(url, redirect: follow)
Fetch-->>getMetaTags: Resolved final URL
getMetaTags->>getMetaTags: Extract image from HTML
alt Image is favicon-like
getMetaTags->>TikTok: Fetch oEmbed thumbnail
TikTok-->>getMetaTags: Video thumbnail
else Image is valid
getMetaTags->>getMetaTags: Use extracted image
end
else Non-TikTok URL
getMetaTags->>getMetaTags: Use standard image extraction
end
getMetaTags->>Meta: Return metadata with final imageUrl
Meta-->>Client: Link preview data
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes: #425
Issue
TikTok links showed favicon or no image instead of the video thumbnail.
Before :-

For a TikTok short URL, ogImage / twitterImage / icon were undefined and finalImage was null.
What I did
For TikTok URLs only: follow short-link redirects, ignore favicon as preview, and use TikTok’s oEmbed API to get the video thumbnail when the page has no image. Other sites unchanged.
Testing
TikTok short and full video URLs show the thumbnail; other links (e.g. dub.co) behave as before.
After fixes:-

Summary by CodeRabbit
Release Notes